package com.doit.demo01;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class test_Date {
    public static void main(String[] args) throws ParseException {
        Date time = new Date();
        System.out.println(time.getTime());//得到毫秒值
        System.out.println(time);//当前时间
        time.setTime(0);//将毫秒值设置为-
        System.out.println(time);
        System.out.println("-----------------------");

        System.out.println(time.toString());
        String tt = time.toString();
//        String s = tt.replaceAll(" ", "");
//        System.out.println();
        Date d = new Date();
        DateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        String s = sdf.format(d);
        System.out.println(s);
        System.out.println("=============================");
        SimpleDateFormat as = new SimpleDateFormat("yyyy年MM月dd日");//日期转成中国式
        System.out.println(as.format(d));
        System.out.println("++++++++++++++++++++++++++++++++");

        String q = "1970-01-02";
        DateFormat sd = new SimpleDateFormat("yyyy-MM-dd");//字符串转日期
        System.out.println(sd.parse(q).getTime());

    }
}
